package com.dfk.bs.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dfk.bs.entity.Eleapp;
import com.dfk.bs.dao.EleappMapper;
import com.dfk.bs.service.EleappService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 用电器表 服务实现类
 * </p>e
 *
 * @author DDK
 * @since 2019-12-12
 */
@Service
public class EleappServiceImpl extends ServiceImpl<EleappMapper, Eleapp> implements EleappService {

    @Override
    public void pageQuery(Page<Eleapp> pageParam, String selectname) {
        QueryWrapper<Eleapp> queryWrapper = new QueryWrapper<>();
        /*查询出来排序 根据表中的sort字段排序*/
        queryWrapper.orderByAsc("sort");
        if (selectname == null) {
            baseMapper.selectPage(pageParam, queryWrapper);
            return;
        }
        /*两个条件  根据用电器id或者状态搜索分页*/
        if (!StringUtils.isEmpty(selectname)) {
            queryWrapper.like("housecode", selectname);
        }
        if (!StringUtils.isEmpty(selectname)) {
            queryWrapper.or().like("status", selectname);
        }
        baseMapper.selectPage(pageParam, queryWrapper);


    }
}
